#ifndef LIST_H
#define	LIST_H

#include <iostream>

struct EmptyList
{
};

template<int value, typename Tail>
struct List
{
   static const int data = value;
   typedef Tail tail;
};

template<typename List>
struct Length
{
   static const int length = 1 + Length<typename List::tail>::length;
};

template<>
struct Length<EmptyList>
{
   static const int length = 0;
};

template<int count, typename list>
struct Prefix
{
   typedef List<list::data, typename Prefix<count - 1, typename list::tail>::result > result;
};

template<typename List>
struct Prefix<0, List>
{
   typedef EmptyList result;
};

template<int count, typename list>
struct Suffix
{
   typedef typename Suffix<count - 1, typename list::tail>::result result;
};

template<typename list>
struct Suffix<0, list>
{
   typedef list result;
};

template<typename List>
void print()
{
   std::cout << List::data << " ";
   print<typename List::tail>();
}

template<>
void print<EmptyList>()
{
   std::cout << "\n";
}

#endif